package com.becca.cake.core.properties;

import java.util.Properties;

import org.apache.commons.lang.StringUtils;

public class Configuration {

    private static Properties properties;

    public static String getProByKey(String key) {
        return properties.getProperty(key);
    }

    public static String getStringByKey(String key) {
        return properties.getProperty(key);
    }

    public static Integer getIntegerByKey(String key) {
        String tempKey = properties.getProperty(key);
        if (StringUtils.isNotBlank(tempKey)) {
            return Integer.valueOf(tempKey);
        }
        return 0;
    }

    public static double getDoubleByKey(String key) {
        String tempKey = properties.getProperty(key);
        if (StringUtils.isNotBlank(tempKey)) {
            return Double.valueOf(tempKey);
        }
        return 0.0;
    }

    public static boolean getBooleanByKey(String key) {
        String tempKey = properties.getProperty(key);
        if (StringUtils.isNotBlank(tempKey)) {
            return Boolean.valueOf(tempKey);
        }
        return false;
    }

    public static Properties getProperties() {
        return properties;
    }

    public static void setProperties(Properties properties) {
        Configuration.properties = properties;
    }

}
